from sqlalchemy import Column, Integer, String, ForeignKey
from sqlalchemy.orm import relationship
from orm_learning.advanced_orm_learning.model import Base
from .permissions import Permissions


class Users(Base):
    __tablename__ = 'users'

    id = Column(Integer, primary_key=True)
    username = Column(String, nullable=False, unique=True)
    password = Column(String, nullable=False)

    permissions = relationship('Permissions', secondary='user_permissions', back_populates='users')